<template>
  <view class="search-container">
    <view class="search-box">
      <view class="search-icon">
        <uni-icons type="search" size="18"></uni-icons>
      </view>
      <input 
        class="search-input" 
        type="text" 
        :placeholder="placeholder" 
        v-model="searchText"
        @confirm="handleSearch"
      />
    </view>
    <view class="search-button" @click="handleSearch">
      <text>搜索</text>
    </view>
  </view>
</template>

<script setup>
import { ref, defineProps, defineEmits } from 'vue';

const props = defineProps({
  placeholder: {
    type: String,
    default: '搜索题目'
  }
});

const emit = defineEmits(['search']);

const searchText = ref('');

const handleSearch = () => {
  emit('search', searchText.value);
};
</script>

<style lang="scss">
.search-container {
  display: flex;
  padding: 20rpx;
  background-color: #fff;
  .search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #f5f5f5;
    border-radius: 40rpx;
    padding: 15rpx 20rpx;
    margin-right: 20rpx;
    
    .search-icon {
      margin-right: 10rpx;
      
      .icon {
        font-size: 36rpx;
        color: #999;
      }
    }
    
    .search-input {
      flex: 1;
      font-size: 28rpx;
      color: #333;
    }
  }
  
  .search-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f6960a;
    color: #fff;
    border-radius: 10rpx;
    padding: 0 30rpx;
    font-size: 28rpx;
  }
}
</style>

